# @Author : mcyj
# @Time : 2025/2/14 下午10:10

import sys
from PySide6.QtWidgets import QApplication, QMainWindow, QWidget, QFileDialog
from MainWinQrc import Ui_MainWindow
from PySide6.QtCore import QCoreApplication
import os

class MainForm(QMainWindow, Ui_MainWindow):
    def __init__(self, parent=None):
        super(MainForm, self).__init__(parent)
        self.setupUi(self)
        #菜单的单击事件,关闭时连接槽函数close()
        self.FileCloseAction.triggered.connect(self.close)
        #菜单的单击事件,打开文件时连接槽函数openMsg()
        self.FileOpenAction.triggered.connect(self.openFile)

        #打开计算器
        self.openCalc.triggered.connect(lambda: os.system("calc"))
        #打开记事本
        self.openNotepad.triggered.connect(lambda: os.system("notepad"))

    def openFile(self):
        file, ok = QFileDialog.getOpenFileName(self, "打开","C:/", "All Files (*);;Text Files (*.txt)")
        #在状态栏显示文件地址
        self.statusbar.showMessage(file)

if __name__ == '__main__':
    app = QApplication(sys.argv)
    main = MainForm()
    main.show()
    sys.exit(app.exec())